Failing to Register Outputs Results in No Components
Here, a subsystem is added as in the previous example, but no outputs
are registered in the parent Model.
This "dead code" is ignored when the CSDL compiler back end constructs a computational model.
from csdl_om import Simulatorfrom csdl import Model, NonlinearBlockGSimport csdlimport numpy as np
class ExampleNoRegisteredOutput(Model):
def define(self): model = Model() a = model.declare_variable('a', val=2) b = model.create_input('b', val=12) model.register_output('prod', a * b) self.add(model, name='sys')
# These expressions are not passed to the compiler back end x1 = self.declare_variable('x1') x2 = self.declare_variable('x2') y1 = x2 + x1 y2 = x2 - x1 y3 = x1 * x2 y5 = x2**2
sim = Simulator(ExampleNoRegisteredOutput())sim.run()
print('prod', sim['prod'].shape)print(sim['prod'])[24.]